import pygame

from view.ui.GameUI import GameUI


class Text:
    def __init__(self, x_position, y_position, foot_path="resources/GenRyuMinTW_Regular.ttf", size=20,
                 color=(255, 255, 255)):
        self.location = [x_position, y_position]
        self.foot = pygame.font.Font(foot_path, size)
        self.text = ""
        self.color = color
        self.image = self.foot.render(self.text, True, self.color)
        self.rect = self.image.get_rect()
        GameUI.add_image_object(self)

    def update(self):
        self.image = self.foot.render(self.text, True, self.color)
        self.rect = self.image.get_rect()
        self.rect.centerx = int(self.location[0] * 48 + 48 - self.rect.width // 2)
        self.rect.bottom = int(self.location[1] * 48 + 96 - self.rect.height)
